package com.ysj.senioradvanced.Handler

import javax.security.auth.callback.Callback

class MyHandler(callback:CallBack) {

    val callback=callback

    init {

    }

    /**
     * 发送消息
     */
    fun sendMsg(msg: MyMessage):Boolean{
        msg.handler=this
        return MyMessageQueue.enqueueMessage(msg)
    }


    /**
     * 分发消息
     */
    fun dispatchMessage(msg: MyMessage){
        println("分发了消息${msg.what}")
        callback?.handlerMessage(msg)
    }


    /**
     * 回调
     */
    interface CallBack{
        fun handlerMessage(msg:MyMessage)
    }
}


